<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            position: absolute;
        }
    </style>
</head>
<body>
    <div>666</div>
    <script>
        var div = document.querySelector('div');
        // keyup 按键弹起触发
        document.onkeyup = function() {
            console.log('弹起');
        }
        //keypress 按键按下触发 区别是不能识别功能键ctrl shift等
        document.addEventListener('keypress',function(e){
            console.log('按下press');
        })
        // keydown 按键按下触发
        document.addEventListener('keydown',function(e){
            console.log('按下');
            // div.style.left += 1 + 'px';
        })
        //执行顺序 keydown keypress keyup
    </script>
</body>
</html>